<%--
 *  File:   zylstdbusinessarea.jsp
 *  @Author: zahirzhong
 *  Date:    2012/08/30
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "DMS";
 	String strTableName = "v_standarddeptpro";
	String privilegeCode = "11341";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>MasterdataRelationship</title>
<PageFlow:CheckPageFlow pageName="p_zylstandarddeptprod"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/inc/CatchError.inc" %>
<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("searchresults");
	HashMap userinfo = (HashMap)session.getAttribute("userinfo");

  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>


<script language="JavaScript" >


function page_summary(actionvalue,orderbyname){
	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "ZylStandardDeptProd.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

var index = 0;
function mathindex(com){
    if(com.checked){
    	index++;
    }else{
    	index--;
    }
}

function page_add(){
	 if(!checkForm(cform)) return;
	 
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}



function page_save(){


var numrows = document.cform.numrows.value;
	for (i=0;i<numrows;i++){
	 var productgroupnameObj= eval("document.cform.productgroupname"+i);
	 if (productgroupnameObj.value ==null ||productgroupnameObj.value==""||productgroupnameObj.value==" ")
	 {
	 alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ProductGroup"))%>");
	 return;
	 }
	}
	cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function set_orgNameByPopWindow(id,code,name){
    var num=document.cform.currentnum.value;
	eval('document.cform.productgroupcode'+num).value=code;
	eval('document.cform.productgroupname'+num).value=name;
	eval('document.cform.prdgroupid'+num).value=id;
	//alert(document.cform.zmylprodgroupid.value);
}



function ProductbrandPop(num){
 	if(num != null || num == ''){
		document.cform.currentnum.value=num;
 	}else{
 	 	document.cform.currentnum.value='';
 	}
    var url = "<%=contextPath%>/masterdata/upm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>";
    attribute = "height=400, width=600,top=120,left=120,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes";

	popwindow = window.open(url,"newwindow1", attribute);
}

</script>

</head>
	
<body>

<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_zylstandarddeptprod">
	<input type="hidden" name="actionname">
	<input type="hidden" name="currentnum"/>
	<input type="hidden" name="numrows" value="<%=totalsummary.size() %>">

<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	<table cellspacing="0" border="0" cellpadding="0">
	   	<tr>
	     	<td><br>
			<table cellspacing="0" border="0" cellpadding="0" onkeydown="if(event.keyCode==13) page_summary('search');">
				<tr>
				    <td width="8%"><%= label.getLabelName("L_Standard_BusinessType") + label.getLabelName("L_Colon")%></td>
				    <td width="12%"><custom:selectdic property ="stdtypesql" dictType="HospitalDepartment" defaultValue="------" defaultValueCost="" /></td>
					<td width="8%"><%= label.getLabelName("L_ProductGroup") + label.getLabelName("L_Colon")%></td>
					<td width="12%"><custom:text property="groupsql"/></td>
                    <td><a href="javascript:page_summary('search')"><img src="<%=contextPath%>/images/<%= strLanguageCode %>/go.gif" border="0" ></a></td>
				</tr>
			</table>	
	     	</td>
	    </tr>
	    <tr> 
		    <td> 
		      <table border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
	    	  <div style="overflow:auto;width:1200px">
		        <tr class="deepblue-left">
				  <td width="1%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
		          <td class="title_center" width="70%"><a href="javascript:page_summary('orderby','standarddeptid')"><%= label.getLabelName("L_Standard_BusinessType") %></a>&nbsp;<span class='red'>*</span></td>
		          <td class="title_center" width="30%" ><a href="javascript:page_summary('orderby','productgroupname')"><%= label.getLabelName("L_ProductGroup") %></a>&nbsp;<span class='red'>*</span></td>
		          </tr>
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
		         <logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
		          	<tr id="tr<%=i-1 %>" class="none">
		          		<td id="td" class="title_center" >
		              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("standarddeptproid") )%>" class="checkbox">
		            	</td>
		            	<td class="title_center">
		            	<custom:hidden  name="onerow"  property="standarddeptproid" colIndex="<%= new Integer(i-1) %>"/>
		            	<custom:hidden  name="onerow"  property="standarddeptid" colIndex="<%= new Integer(i-1) %>"/>
		            	&nbsp;<custom:write name="onerow" property="valuename" nbsp="true"/>
		            	</td>
		            	<td class="title_center">
		            	<custom:text name="onerow" property="productgroupcode" colIndex="<%= new Integer(i-1) %>" />
		            	<a onclick="ProductbrandPop(<%=new Integer(i-1) %>);"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
		            	<custom:text name="onerow" property="productgroupname" colIndex="<%= new Integer(i-1) %>"/>
		            	<custom:hidden  name="onerow"  property="prdgroupid" colIndex="<%= new Integer(i-1) %>"/>
		            	</td>
		            	</td>
		     		 </tr>
		     	 </logic:iterate>
		     	  <tr class="none">
		           <td>&nbsp;</td>
		           <td class="title_center">
		           <custom:selectdic property ="standarddeptid" dictType="HospitalDepartment" defaultValue="-----"  defaultValueCost="" command="notnull" label="L_Standard_BusinessType"/></td>
		           </td>
		           <td class="title_center">
		           <custom:text name="newdetail" property="productgroupcode"/>
		           <a onclick="ProductbrandPop();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
		           <custom:text name="newdetail" property="productgroupname" />
		           <custom:hidden property="prdgroupid" command="notnull" label="L_ProductGroup" name="newdetail"/>
		           </td>
			     </tr>
			  </div>	
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	
		      		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60" privilegeCode="MB-KSCPZ01"/></a>
						<%if(totalsummary.size() >0 ){%>
						<!--<a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="delete.gif" border="0" style="width:60"/></a>  -->
						<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
						<%} %>
					 </td>
				</tr>
		      </table>      
		    </td>
	  </tr>
	
	</table>
</form>
</body>
</html>